﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Linq;
using DTOAuction;
using System.Configuration;

namespace DAOAuction
{
    public class DAOKhoaHoc
    {
        // lấy danh sách khóa học:
        public List<KHOAHOC> layDanhSachTatCaKhoaHoc()
        {
            List<KHOAHOC> lstKhoaHoc = new List<KHOAHOC>();
            using (LinqDataContext db = new LinqDataContext(global::DAOAuction.Properties.Settings.Default.QUANLYGIAODUCConnectionString))
            {
                ISingleResult<KHOAHOC_getallResult> lp = db.KHOAHOC_getall();
                foreach (KHOAHOC_getallResult KHOAHOC in lp)
                {
                    KHOAHOC var1 = new KHOAHOC();
                    var1.MAKHOAHOC = KHOAHOC.MAKHOAHOC;
                    var1.NAMBATDAU = KHOAHOC.NAMBATDAU;
                    var1.NAMKETTHUC = KHOAHOC.NAMKETTHUC;
                    lstKhoaHoc.Add(var1);
                }
                try
                {
                    // Save the changes.
                    db.SubmitChanges();
                }
                // Detect concurrency conflicts.
                catch (ChangeConflictException)
                {
                    // Resolve conflicts.
                    db.ChangeConflicts.ResolveAll(RefreshMode.KeepChanges);
                }
            }
            return lstKhoaHoc;
        }
    }
}
